//
//  WBBarButtonItem+Extension.swift
//  weiboD
//
//  Created by gao2015 on 2016/12/1.
//  Copyright © 2016年 gao2015. All rights reserved.
//

import UIKit
//不能指定构造函数在extention
extension UIBarButtonItem {

    convenience init(title:String,imageName:String? = nil,target: Any?, action: Selector) {//如果参数没有传值就会使用默认值nil
        self.init()
        let btn = UIButton()
        if imageName != nil {
            btn.setImage(UIImage(named:imageName!), for: .normal)
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.gray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        btn.sizeToFit()
        self.customView = btn
    }
    
}
